package net.minecraft.src;

import java.util.Random;

public class BlockPrehistoricPlant extends Block
{

    protected BlockPrehistoricPlant(int i, int j)
    {
        super(i, j, Material.plants);
        setTickOnLoad(true);
        float f = 0.4F;
        setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
    }
	
	public int getBlockTextureFromSideAndMetadata(int i, int j)
    {
        if(j == 1)
        {
            return 39;
        }
        if(j == 2)
        {
            return 56;
        }
        if(j == 0)
        {
            return 55;
        } else
        {
            return 56;
        }
    }
	
	public int getRenderColor(int i)
    {
		return 0x669933;
    }

    public int colorMultiplier(IBlockAccess iblockaccess, int i, int j, int k)
    {
		return 0x669933;
    }

    public boolean canPlaceBlockAt(World world, int i, int j, int k)
    {
        return super.canPlaceBlockAt(world, i, j, k) && canThisPlantGrowOnThisBlockID(world.getBlockId(i, j - 1, k));
    }

    protected boolean canThisPlantGrowOnThisBlockID(int i)
    {
        return i == mod_pph.prehistoricGrass.blockID || i == mod_pph.prehistoricDirt.blockID;
    }

    public void onNeighborBlockChange(World world, int i, int j, int k, int l)
    {
        super.onNeighborBlockChange(world, i, j, k, l);
        checkPlantChange(world, i, j, k);
    }

    public void updateTick(World world, int i, int j, int k, Random random)
    {
        checkPlantChange(world, i, j, k);
    }

    protected final void checkPlantChange(World world, int i, int j, int k)
    {
        if(!canBlockStay(world, i, j, k))
        {
            world.setBlockWithNotify(i, j, k, 0);
        }
    }

    public boolean canBlockStay(World world, int i, int j, int k)
    {
        return (world.getFullBlockLightValue(i, j, k) >= 5 || world.canBlockSeeTheSky(i, j, k)) && canThisPlantGrowOnThisBlockID(world.getBlockId(i, j - 1, k));
    }

    public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
    {
        return null;
    }

    public boolean isOpaqueCube()
    {
        return false;
    }

    public boolean renderAsNormalBlock()
    {
        return false;
    }

    public int getRenderType()
    {
        return mod_pph.renderBlockPlant;
    }
	
	public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l)
    {
        if(world.getBlockMetadata(i, j, k) <= 2 && !world.multiplayerWorld && entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID == Item.shears.shiftedIndex)
        {
            entityplayer.addStat(StatList.mineBlockStatArray[blockID], 1);
            dropBlockAsItem_do(world, i, j, k, new ItemStack(mod_pph.prehistoricPlant, 1, l));
        }
    }
	
	public int idDropped()
    {
        return -1;
    }
	
	public int quantityDropped()
    {
        return 0;
    }
}
